<template>
  <div style="padding: 6px">
    <el-row :gutter="20">
      <el-col :span="4">
        <el-tree ref="orgTree" :data="treeData" node-key="id" :expand-on-click-node="false" default-expand-all  highlight-current @node-click="treeClick"></el-tree>
      </el-col>
      <el-col :span="20">
        <giftList :typeId="activeGiftTypeId" :key="'giftList' + activeGiftTypeId"></giftList>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import request from "@/utils/request";
import giftList from "./giftList";
export default {
  components:{giftList},
  data() {
    return {
      treeData : [],
      activeGiftTypeId : 0,
    }
  },
  mounted() {
    this.loadGiftTypeTree();
  },
  methods: {
    loadGiftTypeTree(){
      request({
        url: '/gift/gifttype/gettreenode',
        data: {}
      }).then(res => {
        const { data } = res
        this.treeData = data
      })
    },
    treeClick(treeNode){
      this.activeGiftTypeId = parseInt(treeNode.id)
    }
  },
}
</script>

<style scoped>

</style>
